<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/common_setting_unit.php"); ?>




<?php

$_REQUEST['ai_belong']="brand";
$_REQUEST['ai_inputtime']=date("Y-m-d H:i:s");


//如果是根目录，品牌的话，补全数据即可
if($_REQUEST['perant_term_nid'] == "root")
{
    echo "品牌";
    $_REQUEST['ai_term1']  = "root";
    $_REQUEST['ai_term0']  = "0";
    $_REQUEST['ai_interm'] = "root";
}



//如果是一级的话，就不用更新了
if($_REQUEST['perant_term_nid'] != "root")
{
    echo "系列";
    $_REQUEST['ai_term0']  = "0";
    $_REQUEST['ai_interm'] = "term1";
    $_REQUEST['ai_term1'] = $_REQUEST['perant_term_nid'] ;


}




//这里是涉及上传文件的部分：包含图片和附件。视频也应该用这种形式上传
//20220315同时把旧的文件，移动到delete中。
//统一设置一下保存图片的路径
$_uf['path']        = ROOT_PATH_ . "/uploadfiles/".$theme_folder."/";

//创建删除文件存放文件夹
if(!file_exists($_uf['path'] ."/delete/")){
    mkdir($_uf['path'] ."/delete/",0777,true);
    chmod($_uf['path'] ."/delete/",0777);
}


//上传icon
if (is_uploaded_file($_FILES['icon']['tmp_name']))
{
    $_uf['upfile']       = $_FILES['icon'];
    $_info               = upload_file($_uf);
    $_REQUEST['ai_icon'] = $_info['name'];
    if(($_REQUEST['ai_icon'])&&($old_detail['icon']!="alpha.gif"))
    {
        rename($_uf['path'].$old_detail['icon'], $_uf['path'] ."delete/".$old_detail['icon']);
    }
}

//上传Banner
if (is_uploaded_file($_FILES['banner']['tmp_name']))
{
    $_uf['upfile']       = $_FILES['banner'];
    $_info               = upload_file($_uf);
    $_REQUEST['ai_banner'] = $_info['name'];
    if(($_REQUEST['ai_banner'])&&($old_detail['banner']!="alpha.gif")){
        rename($_uf['path'].$old_detail['banner'], $_uf['path'] ."delete/".$old_detail['banner']);
    }
}




$insert_sql=insert_date($table_prefix."term",$_REQUEST);


sql_log($insert_sql);
$query = mysql_query($insert_sql) or die ('保存term表失败:'.mysql_error());
mysql_close($con);

?>






<script type="text/javascript">
    alert("输入信息已保存，点击确认返回继续操作.");
    document.location.href = "term-list.php?sys_part=<? echo $system_part ?>";
</script>
